package loengud.w11;

public class PrintThreadSync extends Thread {

	String name;

	public PrintThreadSync(String name) {
		this.name = name;
	}

	public static synchronized void print2(String name) {
		System.out.println("0");
	}
	
	public static synchronized void print(String name) {
		print2(name);
		for (int i = 1; i < 50; i++) {
			try {
				Thread.sleep((long) (Math.random() * 100));
			} catch (InterruptedException ie) {
			}
			System.out.print(name);
		}
	}

	public void run() {
		print(name);
	}

	public static void main(String args[]) {
		PrintThreadSync a = new PrintThreadSync("*");
		PrintThreadSync b = new PrintThreadSync("-");
		PrintThreadSync c = new PrintThreadSync("=");
		a.start();
		b.start();
		c.start();
	}
}


class BankAccount {

	private float balance;

	public synchronized void deposit(float amount) {
		balance += amount;
	}

	public synchronized void withdraw(float amount) {
		balance -= amount;
	}

	public synchronized void transfer(float amount, BankAccount target) {
		withdraw(amount);
		target.deposit(amount);
	}
}
